package com.ruoyi.web.controller.config;

import com.ruoyi.system.mapper.OrdersMapper;
import com.ruoyi.web.controller.system.SysLoginController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;

@Component
public class OrderRefresh {
    private static final Logger log = LoggerFactory.getLogger(OrderRefresh.class);

    @Autowired
    OrdersMapper orderMapper;

    @Scheduled(cron = "0 */5 * * * ?")
    public void refreshOrderStatus() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime oldTime = now.minusHours(24);
        Integer count = orderMapper.waiveOrder(oldTime);
        log.info("执行刷新订单任务，当前时间：" + System.currentTimeMillis() + "，刷新了" + count + "条订单");
    }

}
